package com.xtaller.sdboot.service.impl;

import com.xtaller.sdboot.entity.IamUserRole;
import com.xtaller.sdboot.mapper.IamUserRoleMapper;
import com.xtaller.sdboot.service.IamUserRoleService;
import com.xtaller.sdboot.core.base.impl.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import lombok.var;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/** 
* 代码生成 
* @author: Taller  
* @date: 2020-02-07 15:56:31
* @Description: 用户与角色关系中间表服务实现 
*/ 
@Service 
@Slf4j
public class IamUserRoleServiceImpl extends BaseServiceImpl<IamUserRoleMapper, IamUserRole> implements IamUserRoleService {
    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean setRole(List<IamUserRole> urs) {
        var model = urs.get(0);
        baseMapper.init(model.getUserId(), model.getAppId());
        return this.saveBatch(urs, urs.size());
    }
    @Override
    public boolean initRole(String uid, String appId) {
        return baseMapper.init(uid, appId);
    }
}
